import { wxappid, pwd } from "@/config/config"
import request from "@/utils/request.js"
/**
 * 获取微信公众号js配置
 * @returns {*}
 */
export function getWechatConfig() {
    const signLink = location.href.split('#')[0]
    //获取当前url然后传递给后台获取授权和签名信息，后台需要解码才能使用
    const url = uni.getSystemInfoSync().platform === 'ios' ? uni.getStorageSync('url') : encodeURIComponent(signLink);
    return request.post("yx/wx_sige",{  pwd, url },{ noAuth: true });
}


/**
 * @returns {*}
 */
export function getWechat() {
  return request.get("/userwxw/cli_wz_json",{ pwd },{ noAuth: true });
}

/**
 * 获取微信sdk配置
 * @returns {*}
 */
export function wechatAuth(code, spread) {
	var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ，判断正整数用/^[1-9]+[0-9]*]*$/
	spread = reg.test(spread) ? spread : 0;
  return request.get(
    "wechat/authorize/login?code=" + code + "&spread_spid=" + spread, {},
    { noAuth: true }
  );
}
